package structures.queues;

import java.util.List;
import java.util.Vector;

public class Queue implements IQueueStructure {
    
    private Vector list;
    
    public Queue() {
        this.list = new Vector();
    }
    
    /**
     * Returns the size of elements currently in the queue
     */
    public int size() {
        return this.list.size();
    }
    
    /**
     * Inserts an object in the queue
     */
    public void push(Object obj) {
        this.list.add(obj);
    }
    
    /**
     * Returns the object in front of the queue
     */
    public Object top() {
        if(this.list.size() > 0)
            return this.list.get(0);
        
        return null;
    }
    
    /**
     * Removes and returns the object in front of the queue
     */
    public Object pop() {
        Object returnobj = top();
        
        if(returnobj != null)
            this.list.remove(0);
        
        return returnobj;
    }
    
    public static void main(String [] args) {
        Queue queue = new Queue();
        queue.push(Integer.valueOf(10));
        queue.push(Integer.valueOf(12));
        queue.push(Integer.valueOf(14));
        System.out.println(queue.size());
        System.out.println(queue.top());
        System.out.println(queue.pop());
        System.out.println(queue.top());
        System.out.println(queue.pop());
        System.out.println(queue.top());
        System.out.println(queue.pop());
        System.out.println(queue.top());
        System.out.println(queue.size());  
    }
}
